#include "stdlib.h"
#include "main.h"
#include "stdio.h"

void StringToHex(int size, char *text,char *outbuf)
{
	int i;
	int offset=0;
	int cnt=0;
	for(i = 0; i < size; i++)
	{
		if(text[i] >= '0' && text[i] <= '9')
		text[i] -= '0';
		else if(text[i] >= 'a' && text[i] <= 'f')
		text[i] -= 0x57;
		else if(text[i] >= 'A' && text[i] <= 'F')
		text[i] -= 0x37;
	};
	for(i = 0; i < size; i++)
		{		
			outbuf[i-offset] = text[i]<<4;
			outbuf[i-offset] |= text[i+1];					
			cnt++;offset = cnt;	i++;
		};	
}

void HexToString(char *hexbuf,char *strout,int sizehexbuf)
{
	int i,n = 0;
	for(i = 0; i < sizehexbuf;) 
{
   n += sprintf(strout+n, "%02x",   (unsigned char) hexbuf[i++]);
}
}
